﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DIProject.Dictionary
{
    public partial class Contragents : Form
    {
        public Contragents()
        {
            InitializeComponent();
        }

        private void Contragents_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dictionary.Contragents' table. You can move, or remove it, as needed.
            this.contragentsTableAdapter.Fill(this.dictionary.Contragents);

        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.Rows[e.RowIndex].Selected = true;
            DataRowView dr = dataGridView1.SelectedRows[0].DataBoundItem as DataRowView;
            if (dr != null)
            {
                DataSets.Dictionary.ContragentsRow cr = dr.Row as DataSets.Dictionary.ContragentsRow;
                if (cr != null)
                {
                    ContragentsDetails cd = new ContragentsDetails(Util.ActionType.Update, cr.Id, this);
                    cd.Show(this);
                }
            }
        }
        /// <summary>
        /// кнопка добавить
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ContragentsDetails cd = new ContragentsDetails(Util.ActionType.Insert, Int32.MinValue, this);
            cd.Show(this);
        }
        /// <summary>
        /// кнопка обновить
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.contragentsTableAdapter.Fill(this.dictionary.Contragents);
        }
    }
}